package router

import (
	"github.com/gin-gonic/gin"
	"go-graduation/bff/internal/pkg/output"
	"go-graduation/logger/jaeger"
	"google.golang.org/grpc"
)

type entry struct {
	conn *grpc.ClientConn
}

func NewEntry(conn *grpc.ClientConn) *gin.Engine {
	e := entry{
		conn: conn,
	}
	return e.initEntry()
}

func (e *entry) initEntry() *gin.Engine {
	engine := gin.New()
	//设置路由中间件
	engine.Use(jaeger.SetUp()) // logger.SetUp(),

	engine.NoRoute(func(c *gin.Context) {
		output.NewOutput().Failure(c, 404, "请求方法不存在")
	})
	// 增加版本的路由
	NewV1Router(e.conn, engine).AddRouter()
	return engine
}
